﻿import kliment.ui.ButtonAbstract;
import kliment.ui.ButtonListAbstract;
/**
 * ...
 * @author	Kliment
 * @version	1.1.5
 */
class kliment.ui.menuAbstract.MenuAbstract extends ButtonListAbstract {
	private var _currentButton:ButtonAbstract;
	
	public function MenuAbstract(target_mc:MovieClip, inteval:Number, isParent:Boolean) {
		super(target_mc, inteval, isParent);
	}
	
	public function select(index:Number):Void {
		var item:ButtonAbstract = _buttonsList[index];
		if (item == _currentButton) 
			return;
		_currentButton.resetFocus();
		item.setFocus();
		_currentButton = item;
	}
	
	private function onRelease(target:ButtonAbstract):Void {
		if (target != _currentButton) {
			_currentButton.resetFocus();
			_currentButton = target;
			target.onRelease(target);
			target.onClick(target);
		}
	}
	
	private function onRollOver(target:ButtonAbstract):Void {
		if (target != _currentButton){
			target.setFocus();
		}
	}
	
	private function onRollOut(target:ButtonAbstract):Void {
		if (target != _currentButton){
			target.resetFocus();
		}
	}
	
	private function onReleaseOutside(target:ButtonAbstract):Void {
		if (target != _currentButton){
			target.resetFocus();
		}
	}
	
	public function get current():ButtonAbstract { return _currentButton; }
}